<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>安企神软件 Canvas 示例</title>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        canvas {
            display: block;
        }
    </style>
</head>

<body>
    <canvas id="myCanvas" width="800" height="600"></canvas>
    <script>
        const canvas = document.getElementById('myCanvas');
        const ctx = canvas.getContext('2d');

        function drawTextOnCanvas(text, x, y, size, color) {
            ctx.font = `${size}px Arial`;
            ctx.fillStyle = color;
            ctx.fillText(text, x, y);
        }

        // 设置背景颜色
        ctx.fillStyle = '#f0f0f0';
        ctx.fillRect(0, 0, canvas.width, canvas.height);

        const words = ['安', '企', '神', '软', '件', '安全', '企业', '保护', '软件'];
        const numWords = words.length;

        for (let i = 0; i < numWords; i++) {
            const word = words[i];
            const x = Math.random() * canvas.width;
            const y = Math.random() * canvas.height;
            const size = 20 + Math.random() * 30; // 字体大小范围
            const color = `rgb(${Math.random() * 255}, ${Math.random() * 255}, ${Math.random() * 255})`; // 随机颜色
            drawTextOnCanvas(word, x, y, size, color);
        }
    </script>
</body>

</html>